package com.baitiaojun.system.admin.mapper.user;

import com.baitiaojun.common.enums.impl.UserStatusEnums;
import com.baitiaojun.mybatisplus.core.basemapper.MyBaseMapper;
import com.baitiaojun.system.admin.pojo.SysUserDO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;

public interface UserMapper extends MyBaseMapper<SysUserDO> {
    default boolean exists(String username) {
        LambdaQueryWrapper<SysUserDO> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(SysUserDO::getUserName, username).eq(SysUserDO::getDelFlag, UserStatusEnums.OK.getCode());
        return exists(queryWrapper);
    }

    default boolean createUser(SysUserDO userDO) {
        int insert = insert(userDO);
        return insert == 1;
    }
}
